package com.shenmazong.lambda;

import java.util.function.Supplier;

/**
 * @program: server-java-demo
 * @description: 求数组元素最大值
 * @author: 亮子说编程
 * @create: 2020-10-19 16:11
 **/
public class use_Supplier_Max_Value {
    private static int getMax(Supplier<Integer> suply) {
        return suply.get();
    }
    public static void main(String[] args) {
        Integer [] data = new Integer[] {6,5,4,3,2,1};
        int reslut = getMax(()->{
            int max=0;
            for (int i = 0; i < data.length; i++) {
                max = Math.max(max, data[i]);
            }
            return max;
        });
        System.out.println(reslut);
    }
}
